module Lisp

  class Pair 
    attr_reader(:head, :tail)

    def initialize(head, tail)
      @head, @tail = head, tail
    end

    def to_s
      "head: #{head.to_s}, tail: (#{tail})"
    end

    def ==(other)
      (@head == other.head) && (@tail == other.tail)
    end
  end

  @@empty = Class.new(Pair) do
    def initialize
      super(self, self)
    end

    alias_method(:==, :equal?) #stop the recursion

    def to_s
      "empty"
    end
  end.new

end
